The present disclosure belongs to a technical field of database index, in particular relates to a method and a device for modifying a Lucene index file.
Vehicle information management is one of important functions of a traffic management system, and a database of the system needs to save information of a vehicle passing a plurality of crossroads, such as time, a place, a speed, a vehicle model, a picture, and alarm information. As the database becomes larger and larger and the requirement for a search speed is higher and higher, a search engine such as Lucene is usually needed to recreate the index of data in the database. In this way, a query function of the system still can achieve an ideal response speed even if the quantity of the information saved in the database reaches the level of 1 billion.
However, for objective or subjective reasons, there are potential errors in the information of the database. For example, a community originally affiliated with a certain administrative district is likely to be mistakenly set as a community of other administrative districts by an operator. This kind of information error existing during an index creation is reflected in a Lucene index file, which will lead to an error in a certain field.
The Lucene provides three kinds of operation modes, namely, addition, deletion and modification, to correct the above field error. The operation “addition” is used for adding a document to an existing index folder; the operation “deletion” is used for deleting a document conforming to a specific condition from the index folder; and the operation “modification” is substantially a combination of the operations “addition” and “deletion”, namely, deleting a wrong document from the index folder and adding a right document to the index folder. Thus it can be seen that, the operation “modification” of Lucene does not mean that contents of the index folder can be directly modified, but for partial data with information errors, right data is reacquired from the database to recreate a right index.
However, the creation of index is an extraordinarily time-consuming process. For example, it will take a few days to create indexes of level of 1 billion under a cluster. Therefore, the above operation “modification” becomes quite intolerable in commercial applications.